// src/mock/mockData/loginData.ts
import Mock from 'mockjs';
import { Document, Setting } from '@element-plus/icons-vue'; // 假设你使用的是 Element Plus 的图标

// 模拟登录数据
/*
const loginData = Mock.mock({
  data: {
    "status_code": 200,
    "status": "success",
    "message": "Operation successful.",
    "data": {
        "api_key": "Test",
        "username": "admin",
        "token_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoicTEyMzQ1NjdBYSIsInVzZXJuYW1lIjoiYWRtaW4iLCJyb2xlIjoiYWRtaW4iLCJlbWFpbCI6InVzZXJAZXhhbXBsZS5jb20iLCJleHAiOjE3NDQ2MTQ3MjR9.ZN1CwvBgSa7hSTjvAdduEiJjxlQpxqQp15tM7TEl4xc",
        "role": "admin",
        "email": "user@example.com"
    }
},
});

export default loginData;
*/



// 动态生成登录数据
export default (data: any) => {
  // 解析传入的 data 参数
  const { username, password } = data;

  // 根据用户名和密码生成不同的响应
  if (username === 'admin' && password === 'admin') {
    return Mock.mock({
      status_code: 200,
      status: 'success',
      message: 'Operation successful.',
      data: {
        api_key: 'Test',
        username: 'admin',
        token_key: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoicTEyMzQ1NjdBYSIsInVzZXJuYW1lIjoiYWRtaW4iLCJyb2xlIjoiYWRtaW4iLCJlbWFpbCI6InVzZXJAZXhhbXBsZS5jb20iLCJleHAiOjE3NDQ2MTQ3MjR9.ZN1CwvBgSa7hSTjvAdduEiJjxlQpxqQp15tM7TEl4xc',
        role: 'admin',
        email: 'admin@example.com',
      },
    });
  } else if (username === 'user' && password === 'password') {
    return Mock.mock({
      status_code: 200,
      status: 'success',
      message: 'Operation successful.',
      data: {
        api_key: 'TestUser',
        username: 'user',
        token_key: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoicTEyMzQ1NjdBYSIsInVzZXJuYW1lIjoidXNlciIsInJvbGUiOiJ1c2VyIiwiZW1haWwiOiJ1c2VyQGV4YW1wbGUuY29tIiwiZXhwIjoxNzQ0NjE0NzI0fQ.ZN1CwvBgSa7hSTjvAdduEiJjxlQpxqQp15tM7TEl4xc',
        role: 'user',
        email: 'user@example.com',
      },
    });
  } else {
    return Mock.mock({
      status_code: 401,
      status: 'fail',
      message: 'Invalid username or password.',
      data: null,
    });
  }
};